﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using NS.Utilities;
using NS.BLL.Systems;
using BLL;
using Model;

public partial class Platform_CommuntyManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            GridViewDataBind();
        }
    }

    private void GridViewDataBind()
    {
        FGridView1.SQLString = CommuntyService.GetAllCommunty_SQL(null);
        FGridView1.PKey = "CommuntyID";
        FGridView1.OrderName = "CommuntyID DESC";
        FGridView1.BindData();
        FGridView1.AddControl();
    }
    protected void btnBindData_Click(object sender, EventArgs e)
    {
        GridViewDataBind();
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Communty Model = new Communty();
        Model.CommuntyName = txtCommuntyName.Text.Trim();
        Model.AreaNumber = Area.Value;
        if (CommuntyService.AddCommunty(Model) > 0)
        {
            GridViewDataBind();
        }
        else
        {
            MessageBox.ShowSaveError(this);
        }
    }

    protected void btnDel_Click(object sender, EventArgs e)
    {
        string ID = ((Button)sender).CommandArgument.ToString();
        CommuntyService.DeleteCommuntyByCommuntyID(Convert.ToInt32(ID));
        GridViewDataBind();
    }
}